﻿using Sustainalytics.Claims;
using Sustainalytics.Entities;
using Sustainalytics.ScreeningTool.Service.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;

namespace Sustainalytics.SustainableProducts.Service.Controllers.Helpers
{
    public static class SPClaimsCheckerExtensions
    {
        public static List<string> GetClaimedCompanyIndicators(this IClaimsChecker claimsChecker, ApiController ctrl, IEnumerable<string> piIndicators, string routeKey)
        {
            List<string> claimedSPIndicators = new List<string>();

            foreach (string indValue in piIndicators)
            {
                if (claimsChecker.Validate(ctrl, new List<ResourceParameters> { new ResourceParameters { Key = routeKey, Value = indValue } }))
                {
                    claimedSPIndicators.Add(indValue.ToUpperInvariant());
                }
            }

            return claimedSPIndicators;
        }
    }
}
